<template>
    <div>
        <tableList
            :apis="apis"
            :searchItems="searchItems"
            :headItems="headItems"
            :formItems="formItems"
            @actButEvent="actButEvent"
        ></tableList>
    </div>
</template>

<script>
    export default {
        name: "lidar-location",
        data() {
            return {
                apis: {
                    list: {
                        url: this.$api.V2X_LOCATION_GET,
                        params: {
                            sortedBy: 'desc',
                            orderBy: 'id'
                        }
                    },
                    add: this.$api.V2X_LOCATION_POST,
                    update: this.$api.V2X_LOCATION_PUT,
                    delete: this.$api.V2X_LOCATION_DELETE
                },
                searchItems: [
                    {
                        key: 'location_name',
                        label: this.$t('public.form.name'),
                        placeholder: this.$t('public.form.name'),
                    },
                    {
                        type: "daterange",
                        key: "date",
                        splaceholder: "",
                        eplaceholder: ""
                    }
                ],
                headItems: [
                    { key: 'local_id', label: this.$t('page.lidar.location.headItems.local_id')},
                    { key: 'location_name', label: this.$t('public.form.name')},
                    { key: 'latitude', label: this.$t('public.form.latitude') },
                    { key: 'longitude', label: this.$t('public.form.longitude') },
                    { key: 'created_at', label: this.$t('public.form.created_at'), type: 'datetime' }
                ],
                formItems: [
                    {
                        key: "local_id",
                        label: this.$t('page.lidar.location.headItems.local_id'),
                        rule: ["NotBlank"]
                    },
                    {
                        key: "location_name",
                        label: this.$t('public.form.name'),
                        rule: ["NotBlank"]
                    },
                    {
                        key: "latitude",
                        label: this.$t('public.form.latitude'),
                        rule: ["NotBlank"]
                    },
                    {
                        key: "longitude",
                        label: this.$t('public.form.longitude'),
                        rule: ["NotBlank"]
                    },
                    {
                        key: "location_desciption",
                        label: this.$t('public.form.desc'),
                        type: 'textarea'
                    }
                ],
            }
        },
        methods: {
            actButEvent(e) {
                this[e.eventName](e.val);
            },
            detailAct(e) {
                this.actStatus = e.status;
                this.title = e.time;
                this.id = e.id;
                this.apisAddDeduction.list.params.id = e.id;
                this.dialogDetailActVisible = true;
                this.formLoading = true;
                this.detailHeader();
                this.apisDetailAct.list.params.id = e.id;
                this.apisDetailAct.export.params.id = e.id;
                this.apisDetailAct.total.params.id = e.id;
            },
        }
    }
</script>

<style scoped>

</style>
